package com.ruoyi.transaction.service.impl;

import com.google.common.collect.Maps;
import com.ruoyi.transaction.domain.ExpressCompany;
import com.ruoyi.transaction.mapper.ExpressCompanyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * Created by gzdmt01 on 2019/4/3.
 */
@Service("expressC")
public class expressCompanyService {
    @Autowired
    private ExpressCompanyMapper expressCompanyMapper;
    @Cacheable(cacheNames = "expressCompanyList")
    public List<ExpressCompany> listExpressCompanys(){
        return expressCompanyMapper.listExpressCompanys();
    }

    @Cacheable(cacheNames = "expressCompanyMap")
    public HashMap<Integer,ExpressCompany> mapExpressCompanys(){
        List<ExpressCompany> list=listExpressCompanys();
        HashMap<Integer,ExpressCompany> map=Maps.newHashMap();
        for(ExpressCompany temp:list){
            map.put(temp.getExpressCompanyId(),temp);
        }
        return map;
    }
}
